package com.mycompany.app.hr.pa.model;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EntityResult;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.mycompany.app.hr.pa.model.block4employee.EmployeeBasicInfo;
import com.mycompany.app.hr.pa.model.block4employee.EmployeeContactInfo;
import com.mycompany.app.hr.pa.model.block4employee.EmployeeHireInfo;
import com.mycompany.app.hr.pa.model.block4employee.EmployeeOrgInfo;
import com.mycompany.app.hr.pa.model.block4employee.EmployeePayrollInfo;
import com.mycompany.app.hr.pa.model.dto.SuperiorInfoDTO;

/**
 * Database index: gid, superior_id subordinate
 * 
 * @author Shawn.guo
 */

// ===============named native query==============
@SqlResultSetMapping(name = "employee.getSuperiors.mapping", entities = @EntityResult(entityClass = SuperiorInfoDTO.class))
@NamedNativeQuery(name = "employee.getSuperiors", query = "select e.GID,e.job_title jobTitle, e.SUPERVISOR_GID directSuperiorGid,level from seagate_employee e start with e.GID=? connect by prior e.SUPERVISOR_GID=e.GID", resultSetMapping = "employee.getSuperiors.mapping")
// ===============================================
@SuppressWarnings( { "serial", "unchecked" })
@Entity
@Table(name = "seagate_employee")
public class Employee {

    @Id
    @Column(name = "gid")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;

    @Embedded
    private EmployeeBasicInfo basicInfo=new EmployeeBasicInfo();;

    @Transient
    private EmployeeContactInfo contactInfo=new EmployeeContactInfo();

    @Transient
    private EmployeeHireInfo hireInfo=new EmployeeHireInfo();

    @Embedded
    private EmployeeOrgInfo orgInfo=new EmployeeOrgInfo();

    @Transient
    private EmployeePayrollInfo payrollInfo=new EmployeePayrollInfo();

    // ========================================================

    @Override
    public String toString() {

        return ToStringBuilder.reflectionToString(this,
                ToStringStyle.SHORT_PREFIX_STYLE);
    }

    // ========================================================

    public String getId() {

        return id;
    }

    public void setId(String id) {

        this.id = id;
    }

    public EmployeeBasicInfo getBasicInfo() {

        return basicInfo;
    }

    public void setBasicInfo(EmployeeBasicInfo basicInfo) {

        this.basicInfo = basicInfo;
    }

    public EmployeeContactInfo getContactInfo() {

        return contactInfo;
    }

    public void setContactInfo(EmployeeContactInfo contactInfo) {

        this.contactInfo = contactInfo;
    }

    public EmployeeHireInfo getHireInfo() {

        return hireInfo;
    }

    public void setHireInfo(EmployeeHireInfo hireInfo) {

        this.hireInfo = hireInfo;
    }

    public EmployeeOrgInfo getOrgInfo() {

        return orgInfo;
    }

    public void setOrgInfo(EmployeeOrgInfo orgInfo) {

        this.orgInfo = orgInfo;
    }

    public EmployeePayrollInfo getPayrollInfo() {

        return payrollInfo;
    }

    public void setPayrollInfo(EmployeePayrollInfo payrollInfo) {

        this.payrollInfo = payrollInfo;
    }

}
